/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web.admin
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-4-27
 * @time 下午9:07:42
 */
package com.ssh.web.admin;

import java.io.File;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.entity.InnerVehicle;
import com.ssh.ser.admin.VehicleManageSerI;
import com.ssh.util.UploadFileUtil;

/**
 * @author jack
 *
 */
public class AddInnerVehicleAction extends ActionSupport {
	/**
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	private String type;
	private String vehicleId;
	private String vehicleLevel;
	private String vehiclePicture;
	
	private File vehiclePic;
	private String vehiclePicFileName;

	VehicleManageSerI vehicleManageSerI;

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the vehicleId
	 */
	public String getVehicleId() {
		return vehicleId;
	}

	/**
	 * @param vehicleId
	 *            the vehicleId to set
	 */
	public void setVehicleId(String vehicleId) {
		this.vehicleId = vehicleId;
	}

	/**
	 * @return the vehicleLevel
	 */
	public String getVehicleLevel() {
		return vehicleLevel;
	}

	/**
	 * @param vehicleLevel
	 *            the vehicleLevel to set
	 */
	public void setVehicleLevel(String vehicleLevel) {
		this.vehicleLevel = vehicleLevel;
	}

	/**
	 * @return the vehiclePicture
	 */
	public String getVehiclePicture() {
		return vehiclePicture;
	}

	/**
	 * @param vehiclePicture
	 *            the vehiclePicture to set
	 */
	public void setVehiclePicture(String vehiclePicture) {
		this.vehiclePicture = vehiclePicture;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		try {
			InnerVehicle innerVehicle = new InnerVehicle();
			innerVehicle.setVehicleId(vehicleId);
			innerVehicle.setType(type);
			innerVehicle.setVehicleLevel(vehicleLevel);
			innerVehicle.setVehiclePicture(vehiclePicture);
			
			String path = "upload/image_staff_vehicle";
			boolean sta = UploadFileUtil.save(vehiclePic, vehiclePicFileName, path);
			if(sta){
				innerVehicle.setVehiclePicture(path+"/"+vehiclePicFileName);
			}
			
			
			vehicleManageSerI.addNewVehicle(innerVehicle);
		} catch (Exception e) {
			return "error";
		}
		return "ok";
	}

	/**
	 * @return the vehicleManageSerI
	 */
	public VehicleManageSerI getVehicleManageSerI() {
		return vehicleManageSerI;
	}

	/**
	 * @param vehicleManageSerI
	 *            the vehicleManageSerI to set
	 */
	public void setVehicleManageSerI(VehicleManageSerI vehicleManageSerI) {
		this.vehicleManageSerI = vehicleManageSerI;
	}

	public File getVehiclePic() {
		return vehiclePic;
	}

	public void setVehiclePic(File vehiclePic) {
		this.vehiclePic = vehiclePic;
	}

	public String getVehiclePicFileName() {
		return vehiclePicFileName;
	}

	public void setVehiclePicFileName(String vehiclePicFileName) {
		this.vehiclePicFileName = vehiclePicFileName;
	}

	
}
